package org.four.merchant.controller;

import org.four.common.model.*;
import org.four.merchant.service.MerchantService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

@RestController
@RequestMapping("company")
public class MerchantController {

    @Autowired
    private MerchantService merchantService;

    //登陆：查看账号
    @RequestMapping("findUserInfoByAccount")
    public ComUserBean findUserInfoByAccount(String userName){
        return merchantService.findUserInfoByAccount(userName);
    }

    //注册
    @RequestMapping("regedit")
    public Map regedit(@RequestBody ComUserBean comUserBean, String pwd1){
        Map regedit = merchantService.regedit(comUserBean, pwd1);
        return regedit;
    }

    //完善信息:修改回显
    @RequestMapping("addDatum")
    public ComUserBean addDatum (Integer id){
        return merchantService.addDatum(id);
    }

    //账号信息
    @RequestMapping("companyMessage")
    @ResponseBody
    public ResultBean companyMessage(Integer id){
        return merchantService.companyMessage(id);
    }

    //完善信息:修改保存数据
    @RequestMapping("saveCompanyMessage")
    public ComUserBean saveCompanyMessage(@RequestBody ComUserBean comUserBean){
        return merchantService.saveCompanyMessage(comUserBean);
    }

    //修改密码
    @RequestMapping("editPassWord")
    public void editPassWord(Integer id,String md532){
        merchantService.editPassWord(id,md532);
    }

    //公司：账户查询
    @RequestMapping("findCompanyAccoumt")
    public ResultBean findCompanyAccoumt(Integer id){
        return merchantService.findCompanyAccoumt(id);
    }

    //公司:绑定账号修改 回显
    @RequestMapping("findAccountInfoById")
    public ComTel findAccountInfoById(Integer id){
        return merchantService.findAccountById(id);
    }

    //公司:绑定账号新增、修改
    @RequestMapping("saveCompanyAccount")
    public void saveCompanyAccount(@RequestBody ComTel comTel){
        merchantService.saveCompanyAccount(comTel);
    }


    //查询公司信息
    @RequestMapping("findConypanyMessage")
    public ResultBean findConypanyMessage(Integer id){
        return merchantService.findConypanyMessage(id);
    }


    //修改信息：回显
    @RequestMapping("findCompanyMessageById")
    public CompanyMessage findCompanyMessageById(Integer id){
        return merchantService.findCompanyMessageById(id);
    }

    //新增、修改公司信息
    @RequestMapping("saveCompanyAccountMessage")
    public void saveCompanyAccountMessage(@RequestBody CompanyMessage companyMessage){
         merchantService.saveCompanyAccountMessage(companyMessage);
    }

    //查询套餐
    @RequestMapping("findTaoCan")
    public ResultBean findTaoCan(Integer limit,Integer page){
        return merchantService.findTaoCan(limit,page);
    }


}
